#include "stdafx.h"
#include "CTPQuote.h"
#include "ctp.h"


CCTPQuote::CCTPQuote(void)
{
}


CCTPQuote::~CCTPQuote(void)
{
}

void CCTPQuote::OnFrontConnected()
{
	printf("quote front connected!\n");
	CTP->QLogin();
}

void CCTPQuote::OnFrontDisconnected(int nReason)
{
	printf("quote front disconnect!\n");
}

void CCTPQuote::OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	if (!pRspInfo)
	{
		return;
	}

	if (pRspInfo->ErrorID == 0)
	{
		printf("quote login ok!\n");
		CTP->QSubInstrument();
	}
	else
	{
		printf("quote login err:");
		printf(pRspInfo->ErrorMsg);
		printf("\n");
	}
}

void CCTPQuote::OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	if (!pRspInfo)
	{
		return;
	}

	printf("quote err:");
	printf(pRspInfo->ErrorMsg);
	printf("\n");
}

void CCTPQuote::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData)
{
	ARBITRAGE->OnMarketTick(pDepthMarketData);
}
